home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / firepowr.zip / WEAPONS.QC < prev   
Text File  |  1996-08-11  |  30KB  |  1,349 lines

  1. /*
  2. */
  3. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  4. void () player_run;
  5. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  6. void(vector org, vector vel, float damage) SpawnBlood;
  7. void() SuperDamageSound;
  8.  
  9.  
  10. // called by worldspawn
  11. void() W_Precache =
  12. {
  13.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  14.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  15.     precache_sound ("weapons/sgun1.wav");
  16.     precache_sound ("weapons/guncock.wav");    // player shotgun
  17.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  18.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  19.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  20.     precache_sound ("weapons/spike2.wav");    // super spikes
  21.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  22.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  23.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  24.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  25.  
  26.         precache_model2 ("progs/laser.mdl");  // laser model
  27.         precache_sound2 ("enforcer/enfire.wav"); // laser blaster
  28.         precache_sound2 ("enforcer/enfstop.wav"); // blaster touch
  29.  
  30.         precache_model ("progs/w_spike.mdl");   // green death beam
  31.         precache_sound ("wizard/wattack.wav");  // scary hiss
  32.  
  33.     precache_model2 ("progs/k_spike.mdl");
  34.     precache_sound2 ("hknight/attack1.wav");
  35.  
  36.  
  37.  
  38. };
  39.  
  40. float() crandom =
  41. {
  42.     return 2*(random() - 0.5);
  43. };
  44.  
  45.  
  46. //=============================================================================
  47.  
  48. void() spike_touch;
  49. void() superspike_touch;
  50.  
  51. /*
  52. ===============
  53. launch_spike
  54.  
  55. Used for both the player and the ogre
  56. ===============
  57. */
  58. void(vector org, vector dir) launch_spike =
  59. {
  60.     newmis = spawn ();
  61.     newmis.owner = self;
  62.     newmis.movetype = MOVETYPE_FLYMISSILE;
  63.     newmis.solid = SOLID_BBOX;
  64.  
  65.     newmis.angles = vectoangles(dir);
  66.     
  67.     newmis.touch = spike_touch;
  68.     newmis.classname = "spike";
  69.     newmis.think = SUB_Remove;
  70.     newmis.nextthink = time + 6;
  71.     setmodel (newmis, "progs/spike.mdl");
  72.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  73.     setorigin (newmis, org);
  74.  
  75.     newmis.velocity = dir * 1000;
  76. };
  77.  
  78. /*
  79. ================
  80. W_FireAxe
  81. ================
  82. */
  83. void() W_FireAxe =
  84. {
  85.     local    vector    offang;
  86.     local    vector    org, vec;
  87.  
  88.         local   vector  source;
  89.  
  90.     source = self.origin + '0 0 16';
  91.     traceline (source, source + v_forward*64, FALSE, self);
  92.     if (trace_fraction == 1.0)
  93.         {
  94.                 local vector dst; //
  95.                 dst = aim (self, 1000); //+
  96.                 //offang = vectoangles (dst - self.origin); //&&
  97.                 //offang_y = offang_y + 6; //-
  98.     
  99.                 //makevectors (offang);
  100.  
  101.                 org = self.origin + self.mins + self.size*0.5 + v_forward * 20;
  102.  
  103.         // set missile speed
  104.                 vec = normalize (v_forward);
  105.                 vec_z = vec_z + (random() - 0.5)*0.1;
  106.     
  107.                 launch_spike (org, vec);
  108.                 newmis.classname = "knightspike";
  109.                 setmodel (newmis, "progs/k_spike.mdl");
  110.                 setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  111.                 newmis.velocity = vec*300;
  112.                 newmis.nextthink = time + 5;
  113.                 newmis.think = SUB_Remove;
  114.                 sound (self, CHAN_WEAPON, "hknight/attack1.wav", 1, ATTN_NORM);
  115.         }
  116.         else
  117.         {
  118.                 org = trace_endpos - v_forward*4;
  119.  
  120.                 if (trace_ent.takedamage)
  121.                 {
  122.                         trace_ent.axhitme = 1;
  123.                         SpawnBlood (org, '0 0 0', 20);
  124.                         T_Damage (trace_ent, self, self, 20);
  125.                 }
  126.                 else
  127.                 {       // hit wall
  128.                         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  129.                         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  130.                         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  131.                         WriteCoord (MSG_BROADCAST, org_x);
  132.                         WriteCoord (MSG_BROADCAST, org_y);
  133.                         WriteCoord (MSG_BROADCAST, org_z);
  134.                 }
  135.         }
  136. };
  137.  
  138.  
  139. //============================================================================
  140.  
  141.  
  142. vector() wall_velocity =
  143. {
  144.     local vector    vel;
  145.     
  146.     vel = normalize (self.velocity);
  147.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  148.     vel = vel + 2*trace_plane_normal;
  149.     vel = vel * 200;
  150.     
  151.     return vel;
  152. };
  153.  
  154.  
  155. /*
  156. ================
  157. SpawnMeatSpray
  158. ================
  159. */
  160. void(vector org, vector vel) SpawnMeatSpray =
  161. {
  162.     local    entity missile, mpuff;
  163.     local    vector    org;
  164.  
  165.     missile = spawn ();
  166.     missile.owner = self;
  167.     missile.movetype = MOVETYPE_BOUNCE;
  168.     missile.solid = SOLID_NOT;
  169.  
  170.     makevectors (self.angles);
  171.  
  172.     missile.velocity = vel;
  173.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  174.  
  175.     missile.avelocity = '3000 1000 2000';
  176.     
  177. // set missile duration
  178.     missile.nextthink = time + 1;
  179.     missile.think = SUB_Remove;
  180.  
  181.     setmodel (missile, "progs/zom_gib.mdl");
  182.     setsize (missile, '0 0 0', '0 0 0');        
  183.     setorigin (missile, org);
  184. };
  185.  
  186. /*
  187. ================
  188. SpawnBlood
  189. ================
  190. */
  191. void(vector org, vector vel, float damage) SpawnBlood =
  192. {
  193.     particle (org, vel*0.1, 73, damage*2);
  194. };
  195.  
  196. /*
  197. ================
  198. spawn_touchblood
  199. ================
  200. */
  201. void(float damage) spawn_touchblood =
  202. {
  203.     local vector    vel;
  204.  
  205.     vel = wall_velocity () * 0.2;
  206.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  207. };
  208.  
  209.  
  210. /*
  211. ================
  212. SpawnChunk
  213. ================
  214. */
  215. void(vector org, vector vel) SpawnChunk =
  216. {
  217.     particle (org, vel*0.02, 0, 10);
  218. };
  219.  
  220. /*
  221. ==============================================================================
  222.  
  223. MULTI-DAMAGE
  224.  
  225. Collects multiple small damages into a single damage
  226.  
  227. ==============================================================================
  228. */
  229.  
  230. entity    multi_ent;
  231. float    multi_damage;
  232.  
  233. void() ClearMultiDamage =
  234. {
  235.     multi_ent = world;
  236.     multi_damage = 0;
  237. };
  238.  
  239. void() ApplyMultiDamage =
  240. {
  241.     if (!multi_ent)
  242.         return;
  243.     T_Damage (multi_ent, self, self, multi_damage);
  244. };
  245.  
  246. void(entity hit, float damage) AddMultiDamage =
  247. {
  248.     if (!hit)
  249.         return;
  250.     
  251.     if (hit != multi_ent)
  252.     {
  253.         ApplyMultiDamage ();
  254.         multi_damage = damage;
  255.         multi_ent = hit;
  256.     }
  257.     else
  258.         multi_damage = multi_damage + damage;
  259. };
  260.  
  261. /*
  262. ==============================================================================
  263.  
  264. BULLETS
  265.  
  266. ==============================================================================
  267. */
  268.  
  269. /*
  270. ================
  271. TraceAttack
  272. ================
  273. */
  274. void(float damage, vector dir) TraceAttack =
  275. {
  276.     local    vector    vel, org;
  277.     
  278.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  279.     vel = vel + 2*trace_plane_normal;
  280.     vel = vel * 200;
  281.  
  282.     org = trace_endpos - dir*4;
  283.  
  284.     if (trace_ent.takedamage)
  285.     {
  286.         SpawnBlood (org, vel*0.2, damage);
  287.         AddMultiDamage (trace_ent, damage);
  288.     }
  289.     else
  290.     {
  291.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  292.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  293.         WriteCoord (MSG_BROADCAST, org_x);
  294.         WriteCoord (MSG_BROADCAST, org_y);
  295.         WriteCoord (MSG_BROADCAST, org_z);
  296.     }
  297. };
  298.  
  299. /*
  300. ================
  301. FireBullets
  302.  
  303. Used by shotgun, super shotgun, and enemy soldier firing
  304. Go to the trouble of combining multiple pellets into a single damage call.
  305. ================
  306. */
  307. void(float shotcount, vector dir, vector spread) FireBullets =
  308. {
  309.     local    vector direction;
  310.     local    vector    src;
  311.     
  312.     makevectors(self.v_angle);
  313.  
  314.     src = self.origin + v_forward*10;
  315.     src_z = self.absmin_z + self.size_z * 0.7;
  316.  
  317.     ClearMultiDamage ();
  318.     while (shotcount > 0)
  319.     {
  320.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  321.  
  322.         traceline (src, src + direction*2048, FALSE, self);
  323.         if (trace_fraction != 1.0)
  324.             TraceAttack (4, direction);
  325.  
  326.         shotcount = shotcount - 1;
  327.     }
  328.     ApplyMultiDamage ();
  329. };
  330.  
  331. /*
  332. ================
  333. W_FireShotgun   //////// Laser Blaster Hacked in by Freak 
  334. ================
  335. */
  336.  
  337. void() Blaster_Touch =
  338. {
  339.     local vector org;
  340.     
  341.     if (other == self.owner)
  342.         return;        // don't explode on owner
  343.  
  344.     if (pointcontents(self.origin) == CONTENT_SKY)
  345.     {
  346.         remove(self);
  347.         return;
  348.     }
  349.     
  350.     sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
  351.     org = self.origin - 8*normalize(self.velocity);
  352.  
  353.     if (other.health)
  354.     {
  355.                 SpawnBlood (org, self.velocity*0.2, 10);
  356.                 T_Damage (other, self, self.owner, 10);
  357.     }
  358.     else
  359.     {
  360.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  361.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  362.         WriteCoord (MSG_BROADCAST, org_x);
  363.         WriteCoord (MSG_BROADCAST, org_y);
  364.         WriteCoord (MSG_BROADCAST, org_z);
  365.     }
  366.     
  367.     remove(self);    
  368. };
  369.  
  370. void() W_FireShotgun =
  371. {
  372.         local vector dir;
  373. //        local   vector  vec;
  374.     local vector org;
  375.  
  376.         sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM); 
  377.  
  378.     dir = aim (self, 100000);
  379.         dir = normalize(dir);
  380.  
  381.     newmis = spawn();
  382.     newmis.owner = self;
  383.     newmis.movetype = MOVETYPE_FLY;
  384.     newmis.solid = SOLID_BBOX;
  385.     newmis.effects = EF_DIMLIGHT;
  386.  
  387.     setmodel (newmis, "progs/laser.mdl");
  388.     setsize (newmis, '0 0 0', '0 0 0');        
  389.  
  390.         self.effects = self.effects | EF_MUZZLEFLASH;     //?
  391.         makevectors (self.angles);                        // huh?
  392.     
  393.         org = self.origin + v_forward * 0 + v_right * 0 + '0 0 0';  //was v_forward * 30, '0 0 12'
  394.     setorigin (newmis, org);
  395.  
  396.         newmis.velocity = dir * 600;
  397.     newmis.angles = vectoangles(newmis.velocity);
  398. //
  399. //      self.punchangle_x = -2;
  400.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  401.  
  402.     newmis.nextthink = time + 5;
  403.     newmis.think = SUB_Remove;
  404.         newmis.touch = Blaster_Touch;
  405.  
  406. //      FireBullets (6, dir, '0.04 0.04 0');
  407. };
  408.  
  409.  
  410. /*
  411. ================
  412. W_FireSuperShotgun
  413. ================
  414. */
  415. void() W_FireSuperShotgun =
  416. {
  417.     local vector dir;
  418.  
  419.     if (self.currentammo == 1)
  420.     {
  421.         W_FireShotgun ();
  422.         return;
  423.     }
  424.         
  425.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  426.  
  427.     self.punchangle_x = -4;
  428.     
  429.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  430.     dir = aim (self, 100000);
  431.         FireBullets (28, dir, '0.14 0.08 0');
  432. };
  433.  
  434.  
  435. /*
  436. ==============================================================================
  437.  
  438. ROCKETS
  439.  
  440. ==============================================================================
  441. */
  442.  
  443. void()    s_explode1    =    [0,        s_explode2] {};
  444. void()    s_explode2    =    [1,        s_explode3] {};
  445. void()    s_explode3    =    [2,        s_explode4] {};
  446. void()    s_explode4    =    [3,        s_explode5] {};
  447. void()    s_explode5    =    [4,        s_explode6] {};
  448. void()    s_explode6    =    [5,        SUB_Remove] {};
  449.  
  450. void() BecomeExplosion =
  451. {
  452.     self.movetype = MOVETYPE_NONE;
  453.     self.velocity = '0 0 0';
  454.     self.touch = SUB_Null;
  455.     setmodel (self, "progs/s_explod.spr");
  456.     self.solid = SOLID_NOT;
  457.     s_explode1 ();
  458. };
  459.  
  460. void() T_MissileTouch =
  461. {
  462.     local float    damg;
  463.  
  464.     if (other == self.owner)
  465.         return;        // don't explode on owner
  466.  
  467.     if (pointcontents(self.origin) == CONTENT_SKY)
  468.     {
  469.         remove(self);
  470.         return;
  471.     }
  472.  
  473.     damg = 100 + random()*20;
  474.     
  475.     if (other.health)
  476.     {
  477.         if (other.classname == "monster_shambler")
  478.             damg = damg * 0.5;    // mostly immune
  479.         T_Damage (other, self, self.owner, damg );
  480.     }
  481.  
  482.     // don't do radius damage to the other, because all the damage
  483.     // was done in the impact
  484.     T_RadiusDamage (self, self.owner, 120, other);
  485.  
  486. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  487.     self.origin = self.origin - 8*normalize(self.velocity);
  488.  
  489.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  490.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  491.     WriteCoord (MSG_BROADCAST, self.origin_x);
  492.     WriteCoord (MSG_BROADCAST, self.origin_y);
  493.     WriteCoord (MSG_BROADCAST, self.origin_z);
  494.  
  495.     BecomeExplosion ();
  496. };
  497.  
  498.  
  499.  
  500. /*
  501. ================
  502. W_FireRocket
  503. ================
  504. */
  505. void() W_FireRocket =
  506. {
  507.     local    entity missile, mpuff;
  508.     
  509.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  510.     
  511.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  512.  
  513.     self.punchangle_x = -2;
  514.  
  515.     missile = spawn ();
  516.     missile.owner = self;
  517.     missile.movetype = MOVETYPE_FLYMISSILE;
  518.     missile.solid = SOLID_BBOX;
  519.         
  520. // set missile speed    
  521.  
  522.     makevectors (self.v_angle);
  523.     missile.velocity = aim(self, 1000);
  524.     missile.velocity = missile.velocity * 1000;
  525.     missile.angles = vectoangles(missile.velocity);
  526.     
  527.     missile.touch = T_MissileTouch;
  528.     
  529. // set missile duration
  530.     missile.nextthink = time + 5;
  531.     missile.think = SUB_Remove;
  532.  
  533.     setmodel (missile, "progs/missile.mdl");
  534.     setsize (missile, '0 0 0', '0 0 0');        
  535.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  536. };
  537.  
  538. /*
  539. ===============================================================================
  540.  
  541. LIGHTNING
  542.  
  543. ===============================================================================
  544. */
  545.  
  546. /*
  547. =================
  548. LightningDamage
  549. =================
  550. */
  551. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  552. {
  553.     local entity        e1, e2;
  554.     local vector        f;
  555.     
  556.     f = p2 - p1;
  557.     normalize (f);
  558.     f_x = 0 - f_y;
  559.     f_y = f_x;
  560.     f_z = 0;
  561.     f = f*16;
  562.  
  563.     e1 = e2 = world;
  564.  
  565.     traceline (p1, p2, FALSE, self);
  566.     if (trace_ent.takedamage)
  567.     {
  568.         particle (trace_endpos, '0 0 100', 225, damage*4);
  569.         T_Damage (trace_ent, from, from, damage);
  570.         if (self.classname == "player")
  571.         {
  572.             if (other.classname == "player")
  573.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  574.         }
  575.     }
  576.     e1 = trace_ent;
  577.  
  578.     traceline (p1 + f, p2 + f, FALSE, self);
  579.     if (trace_ent != e1 && trace_ent.takedamage)
  580.     {
  581.         particle (trace_endpos, '0 0 100', 225, damage*4);
  582.         T_Damage (trace_ent, from, from, damage);
  583.     }
  584.     e2 = trace_ent;
  585.  
  586.     traceline (p1 - f, p2 - f, FALSE, self);
  587.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  588.     {
  589.         particle (trace_endpos, '0 0 100', 225, damage*4);
  590.         T_Damage (trace_ent, from, from, damage);
  591.     }
  592. };
  593.  
  594.  
  595. void() W_FireLightning =
  596. {
  597.     local    vector        org;
  598.  
  599.     if (self.ammo_cells < 1)
  600.     {
  601.         self.weapon = W_BestWeapon ();
  602.         W_SetCurrentAmmo ();
  603.         return;
  604.     }
  605.  
  606. // explode if under water
  607.     if (self.waterlevel > 1)
  608.     {
  609.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  610.         self.ammo_cells = 0;
  611.         W_SetCurrentAmmo ();
  612.         return;
  613.     }
  614.  
  615.     if (self.t_width < time)
  616.     {
  617.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  618.         self.t_width = time + 0.6;
  619.     }
  620.     self.punchangle_x = -2;
  621.  
  622.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  623.  
  624.     org = self.origin + '0 0 16';
  625.     
  626.     traceline (org, org + v_forward*600, TRUE, self);
  627.  
  628.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  629.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  630.     WriteEntity (MSG_BROADCAST, self);
  631.     WriteCoord (MSG_BROADCAST, org_x);
  632.     WriteCoord (MSG_BROADCAST, org_y);
  633.     WriteCoord (MSG_BROADCAST, org_z);
  634.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  635.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  636.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  637.  
  638.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  639. };
  640.  
  641.  
  642. //=============================================================================
  643.  
  644.  
  645. void() GrenadeExplode =
  646. {
  647.     T_RadiusDamage (self, self.owner, 120, world);
  648.  
  649.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  650.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  651.     WriteCoord (MSG_BROADCAST, self.origin_x);
  652.     WriteCoord (MSG_BROADCAST, self.origin_y);
  653.     WriteCoord (MSG_BROADCAST, self.origin_z);
  654.  
  655.     BecomeExplosion ();
  656. };
  657.  
  658. void() GrenadeTouch =
  659. {
  660.     if (other == self.owner)
  661.         return;        // don't explode on owner
  662.     if (other.takedamage == DAMAGE_AIM)
  663.     {
  664.         GrenadeExplode();
  665.         return;
  666.     }
  667.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  668.     if (self.velocity == '0 0 0')
  669.         self.avelocity = '0 0 0';
  670. };
  671.  
  672. /*
  673. ================
  674. W_FireGrenade
  675. ================
  676. */
  677. void() W_FireGrenade =
  678. {
  679.     local    entity missile, mpuff;
  680.     
  681.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  682.     
  683.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  684.  
  685.     self.punchangle_x = -2;
  686.  
  687.     missile = spawn ();
  688.     missile.owner = self;
  689.     missile.movetype = MOVETYPE_BOUNCE;
  690.     missile.solid = SOLID_BBOX;
  691.     missile.classname = "grenade";
  692.         
  693. // set missile speed    
  694.  
  695.     makevectors (self.v_angle);
  696.  
  697.     if (self.v_angle_x)
  698.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  699.     else
  700.     {
  701.         missile.velocity = aim(self, 10000);
  702.         missile.velocity = missile.velocity * 600;
  703.         missile.velocity_z = 200;
  704.     }
  705.  
  706.     missile.avelocity = '300 300 300';
  707.  
  708.     missile.angles = vectoangles(missile.velocity);
  709.     
  710.     missile.touch = GrenadeTouch;
  711.     
  712. // set missile duration
  713.     missile.nextthink = time + 2.5;
  714.     missile.think = GrenadeExplode;
  715.  
  716.     setmodel (missile, "progs/grenade.mdl");
  717.     setsize (missile, '0 0 0', '0 0 0');        
  718.     setorigin (missile, self.origin);
  719. };
  720.  
  721.  
  722. void() W_FireSuperSpikes =
  723. {
  724.     local vector    dir;
  725.     local entity    old;
  726.     
  727.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  728.     self.attack_finished = time + 0.2;
  729.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  730.     dir = aim (self, 1000);
  731.     launch_spike (self.origin + '0 0 16', dir);
  732.     newmis.touch = superspike_touch;
  733.     setmodel (newmis, "progs/s_spike.mdl");
  734.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  735.     self.punchangle_x = -2;
  736. };
  737.  
  738. //////////////////////////////////////////Green Death Beams, Hacked by Freak
  739.  
  740.  
  741. void(float ox) W_FireSpikes =
  742. {
  743.         
  744.     local vector    dir;
  745.         local entity    old;
  746.  
  747.         makevectors (self.v_angle);
  748.     
  749.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  750.     {
  751.         W_FireSuperSpikes ();
  752.         return;
  753.     }
  754.  
  755.     if (self.ammo_nails < 1)
  756.     {
  757.         self.weapon = W_BestWeapon ();
  758.         W_SetCurrentAmmo ();
  759.         return;
  760.     }
  761.  
  762.     sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM);
  763.         self.attack_finished = time + 0.2;
  764.         self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  765.         dir = aim (self, 1000);
  766.         launch_spike(self.origin + '0 0 16' + v_right*ox, dir);
  767.         dir = normalize(dir);
  768.         newmis.velocity = dir*850;
  769.         newmis.classname = "wizspike";
  770.         setmodel (newmis, "progs/w_spike.mdl");
  771.  
  772.         newmis.nextthink = time + 5;
  773.     newmis.think = SUB_Remove;
  774.  
  775.  
  776.     self.punchangle_x = -2;
  777.  
  778.  
  779. };
  780.  
  781.  
  782.  
  783. .float hit_z;
  784. void() spike_touch =
  785. {
  786. local float rand;
  787.     if (other == self.owner)
  788.         return;
  789.  
  790.     if (other.solid == SOLID_TRIGGER)
  791.         return;    // trigger field, do nothing
  792.  
  793.     if (pointcontents(self.origin) == CONTENT_SKY)
  794.     {
  795.         remove(self);
  796.         return;
  797.     }
  798.     
  799. // hit something that bleeds            /////// Change numbers here for
  800.                                         /////// Green Stream and Hell Hatchet
  801.         if (other.takedamage)           /////// Damage values
  802.     {
  803.         if (self.classname == "wizspike")
  804.                 {
  805.                         spawn_touchblood (5);
  806.                         T_Damage (other, self, self.owner, 5);
  807.                 }        
  808.         else if (self.classname == "knightspike")
  809.                 {
  810.                         spawn_touchblood (12);
  811.                         T_Damage (other, self, self.owner, 12);
  812.                 }
  813.                 else
  814.                 {
  815.                         spawn_touchblood (9);
  816.                         T_Damage (other, self, self.owner, 9);
  817.                 }
  818.     }
  819.     else
  820.     {
  821.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  822.         
  823.         if (self.classname == "wizspike")
  824.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  825.         else if (self.classname == "knightspike")
  826.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  827.         else
  828.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  829.         WriteCoord (MSG_BROADCAST, self.origin_x);
  830.         WriteCoord (MSG_BROADCAST, self.origin_y);
  831.         WriteCoord (MSG_BROADCAST, self.origin_z);
  832.     }
  833.  
  834.     remove(self);
  835.  
  836. };
  837.  
  838. void() superspike_touch =
  839. {
  840. local float rand;
  841.     if (other == self.owner)
  842.         return;
  843.  
  844.     if (other.solid == SOLID_TRIGGER)
  845.         return;    // trigger field, do nothing
  846.  
  847.     if (pointcontents(self.origin) == CONTENT_SKY)
  848.     {
  849.         remove(self);
  850.         return;
  851.     }
  852.     
  853. // hit something that bleeds                  //// Change here for supernail
  854.         if (other.takedamage)                 //// damage 
  855.     {
  856.         spawn_touchblood (18);
  857.         T_Damage (other, self, self.owner, 18);
  858.     }
  859.     else
  860.     {
  861.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  862.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  863.         WriteCoord (MSG_BROADCAST, self.origin_x);
  864.         WriteCoord (MSG_BROADCAST, self.origin_y);
  865.         WriteCoord (MSG_BROADCAST, self.origin_z);
  866.     }
  867.  
  868.     remove(self);
  869.  
  870. };
  871.  
  872.  
  873. /*
  874. ===============================================================================
  875.  
  876. PLAYER WEAPON USE
  877.  
  878. ===============================================================================
  879. */
  880.  
  881. void() W_SetCurrentAmmo =
  882. {
  883.     player_run ();        // get out of any weapon firing states
  884.  
  885.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  886.     
  887.     if (self.weapon == IT_AXE)
  888.     {
  889.         self.currentammo = 0;
  890.         self.weaponmodel = "progs/v_axe.mdl";
  891.         self.weaponframe = 0;
  892.     }
  893.     else if (self.weapon == IT_SHOTGUN)
  894.     {
  895.         self.currentammo = self.ammo_shells;
  896.         self.weaponmodel = "progs/v_shot.mdl";
  897.         self.weaponframe = 0;
  898.         self.items = self.items | IT_SHELLS;
  899.     }
  900.     else if (self.weapon == IT_SUPER_SHOTGUN)
  901.     {
  902.         self.currentammo = self.ammo_shells;
  903.         self.weaponmodel = "progs/v_shot2.mdl";
  904.         self.weaponframe = 0;
  905.         self.items = self.items | IT_SHELLS;
  906.     }
  907.     else if (self.weapon == IT_NAILGUN)
  908.     {
  909.         self.currentammo = self.ammo_nails;
  910.         self.weaponmodel = "progs/v_nail.mdl";
  911.         self.weaponframe = 0;
  912.         self.items = self.items | IT_NAILS;
  913.     }
  914.     else if (self.weapon == IT_SUPER_NAILGUN)
  915.     {
  916.         self.currentammo = self.ammo_nails;
  917.         self.weaponmodel = "progs/v_nail2.mdl";
  918.         self.weaponframe = 0;
  919.         self.items = self.items | IT_NAILS;
  920.     }
  921.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  922.     {
  923.         self.currentammo = self.ammo_rockets;
  924.         self.weaponmodel = "progs/v_rock.mdl";
  925.         self.weaponframe = 0;
  926.         self.items = self.items | IT_ROCKETS;
  927.     }
  928.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  929.     {
  930.         self.currentammo = self.ammo_rockets;
  931.         self.weaponmodel = "progs/v_rock2.mdl";
  932.         self.weaponframe = 0;
  933.         self.items = self.items | IT_ROCKETS;
  934.     }
  935.     else if (self.weapon == IT_LIGHTNING)
  936.     {
  937.         self.currentammo = self.ammo_cells;
  938.         self.weaponmodel = "progs/v_light.mdl";
  939.         self.weaponframe = 0;
  940.         self.items = self.items | IT_CELLS;
  941.     }
  942.     else
  943.     {
  944.         self.currentammo = 0;
  945.         self.weaponmodel = "";
  946.         self.weaponframe = 0;
  947.     }
  948. };
  949.  
  950. float() W_BestWeapon =
  951. {
  952.     local    float    it;
  953.     
  954.     it = self.items;
  955.  
  956.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  957.         return IT_LIGHTNING;
  958.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  959.         return IT_SUPER_NAILGUN;
  960.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  961.         return IT_SUPER_SHOTGUN;
  962.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  963.         return IT_NAILGUN;
  964.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  965.         return IT_SHOTGUN;
  966.         
  967. /*
  968.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  969.         return IT_ROCKET_LAUNCHER;
  970.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  971.         return IT_GRENADE_LAUNCHER;
  972.  
  973. */
  974.  
  975.     return IT_AXE;
  976. };
  977.  
  978. float() W_CheckNoAmmo =
  979. {
  980.     if (self.currentammo > 0)
  981.         return TRUE;
  982.  
  983.     if (self.weapon == IT_AXE)
  984.         return TRUE;
  985.     
  986.     self.weapon = W_BestWeapon ();
  987.  
  988.     W_SetCurrentAmmo ();
  989.     
  990. // drop the weapon down
  991.     return FALSE;
  992. };
  993.  
  994. /*
  995. ============
  996. W_Attack
  997.  
  998. An attack impulse can be triggered now
  999. ============
  1000. */
  1001. void()    player_axe1;
  1002. void()    player_axeb1;
  1003. void()    player_axec1;
  1004. void()    player_axed1;
  1005. void()    player_shot1;
  1006. void()    player_nail1;
  1007. void()    player_light1;
  1008. void()    player_rocket1;
  1009.  
  1010. void() W_Attack =
  1011. {
  1012.     local    float    r;
  1013.  
  1014.     if (!W_CheckNoAmmo ())
  1015.         return;
  1016.  
  1017.     makevectors    (self.v_angle);            // calculate forward angle for velocity
  1018.     self.show_hostile = time + 1;    // wake monsters up
  1019.  
  1020.     if (self.weapon == IT_AXE)
  1021.     {
  1022.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1023.         r = random();
  1024.         if (r < 0.25)
  1025.             player_axe1 ();
  1026.         else if (r<0.5)
  1027.             player_axeb1 ();
  1028.         else if (r<0.75)
  1029.             player_axec1 ();
  1030.         else
  1031.             player_axed1 ();
  1032.                 self.attack_finished = time + 0.3;   // originally .5
  1033.     }
  1034.         else if (self.weapon == IT_SHOTGUN) /// Actually the laser blaster
  1035.     {
  1036.         player_shot1 ();
  1037.         W_FireShotgun ();
  1038.                 self.attack_finished = time + 0.1;
  1039.     }
  1040.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1041.     {
  1042.         player_shot1 ();
  1043.         W_FireSuperShotgun ();
  1044.                 self.attack_finished = time + 0.9;
  1045.     }
  1046.     else if (self.weapon == IT_NAILGUN)
  1047.     {
  1048.         player_nail1 ();
  1049.     }
  1050.     else if (self.weapon == IT_SUPER_NAILGUN)
  1051.     {
  1052.         player_nail1 ();
  1053.     }
  1054.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1055.     {
  1056.         player_rocket1();
  1057.         W_FireGrenade();
  1058.         self.attack_finished = time + 0.6;
  1059.     }
  1060.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1061.     {
  1062.         player_rocket1();
  1063.         W_FireRocket();
  1064.         self.attack_finished = time + 0.8;
  1065.     }
  1066.     else if (self.weapon == IT_LIGHTNING)
  1067.     {
  1068.         player_light1();
  1069.         self.attack_finished = time + 0.1;
  1070.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1071.     }
  1072. };
  1073.  
  1074. /*
  1075. ============
  1076. W_ChangeWeapon
  1077.  
  1078. ============
  1079. */
  1080. void() W_ChangeWeapon =
  1081. {
  1082.     local    float    it, am, fl;
  1083.     
  1084.     it = self.items;
  1085.     am = 0;
  1086.     
  1087.     if (self.impulse == 1)
  1088.     {
  1089.         fl = IT_AXE;
  1090.     }
  1091.     else if (self.impulse == 2)
  1092.     {
  1093.         fl = IT_SHOTGUN;
  1094.         if (self.ammo_shells < 1)
  1095.             am = 1;
  1096.     }
  1097.     else if (self.impulse == 3)
  1098.     {
  1099.         fl = IT_SUPER_SHOTGUN;
  1100.         if (self.ammo_shells < 2)
  1101.             am = 1;
  1102.     }        
  1103.     else if (self.impulse == 4)
  1104.     {
  1105.         fl = IT_NAILGUN;
  1106.         if (self.ammo_nails < 1)
  1107.             am = 1;
  1108.     }
  1109.     else if (self.impulse == 5)
  1110.     {
  1111.         fl = IT_SUPER_NAILGUN;
  1112.         if (self.ammo_nails < 2)
  1113.             am = 1;
  1114.     }
  1115.     else if (self.impulse == 6)
  1116.     {
  1117.         fl = IT_GRENADE_LAUNCHER;
  1118.         if (self.ammo_rockets < 1)
  1119.             am = 1;
  1120.     }
  1121.     else if (self.impulse == 7)
  1122.     {
  1123.         fl = IT_ROCKET_LAUNCHER;
  1124.         if (self.ammo_rockets < 1)
  1125.             am = 1;
  1126.     }
  1127.     else if (self.impulse == 8)
  1128.     {
  1129.         fl = IT_LIGHTNING;
  1130.         if (self.ammo_cells < 1)
  1131.             am = 1;
  1132.     }
  1133.  
  1134.     self.impulse = 0;
  1135.     
  1136.     if (!(self.items & fl))
  1137.     {    // don't have the weapon or the ammo
  1138.         sprint (self, "no weapon.\n");
  1139.         return;
  1140.     }
  1141.     
  1142.     if (am)
  1143.     {    // don't have the ammo
  1144.         sprint (self, "not enough ammo.\n");
  1145.         return;
  1146.     }
  1147.  
  1148. //
  1149. // set weapon, set ammo
  1150. //
  1151.     self.weapon = fl;        
  1152.     W_SetCurrentAmmo ();
  1153. };
  1154.  
  1155. /*
  1156. ============
  1157. CheatCommand
  1158. ============
  1159. */
  1160. void() CheatCommand =
  1161. {
  1162.     if (deathmatch || coop)
  1163.         return;
  1164.  
  1165.     self.ammo_rockets = 100;
  1166.     self.ammo_nails = 200;
  1167.     self.ammo_shells = 100;
  1168.     self.items = self.items | 
  1169.         IT_AXE |
  1170.         IT_SHOTGUN |
  1171.         IT_SUPER_SHOTGUN |
  1172.         IT_NAILGUN |
  1173.         IT_SUPER_NAILGUN |
  1174.         IT_GRENADE_LAUNCHER |
  1175.         IT_ROCKET_LAUNCHER |
  1176.         IT_KEY1 | IT_KEY2;
  1177.  
  1178.     self.ammo_cells = 200;
  1179.     self.items = self.items | IT_LIGHTNING;
  1180.  
  1181.     self.weapon = IT_ROCKET_LAUNCHER;
  1182.     self.impulse = 0;
  1183.     W_SetCurrentAmmo ();
  1184. };
  1185.  
  1186. /*
  1187. ============
  1188. CycleWeaponCommand
  1189.  
  1190. Go to the next weapon with ammo
  1191. ============
  1192. */
  1193. void() CycleWeaponCommand =
  1194. {
  1195.     local    float    it, am;
  1196.     
  1197.     it = self.items;
  1198.     self.impulse = 0;
  1199.     
  1200.     while (1)
  1201.     {
  1202.         am = 0;
  1203.  
  1204.         if (self.weapon == IT_LIGHTNING)
  1205.         {
  1206.             self.weapon = IT_AXE;
  1207.         }
  1208.         else if (self.weapon == IT_AXE)
  1209.         {
  1210.             self.weapon = IT_SHOTGUN;
  1211.             if (self.ammo_shells < 1)
  1212.                 am = 1;
  1213.         }
  1214.         else if (self.weapon == IT_SHOTGUN)
  1215.         {
  1216.             self.weapon = IT_SUPER_SHOTGUN;
  1217.             if (self.ammo_shells < 2)
  1218.                 am = 1;
  1219.         }        
  1220.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1221.         {
  1222.             self.weapon = IT_NAILGUN;
  1223.             if (self.ammo_nails < 1)
  1224.                 am = 1;
  1225.         }
  1226.         else if (self.weapon == IT_NAILGUN)
  1227.         {
  1228.             self.weapon = IT_SUPER_NAILGUN;
  1229.             if (self.ammo_nails < 2)
  1230.                 am = 1;
  1231.         }
  1232.         else if (self.weapon == IT_SUPER_NAILGUN)
  1233.         {
  1234.             self.weapon = IT_GRENADE_LAUNCHER;
  1235.             if (self.ammo_rockets < 1)
  1236.                 am = 1;
  1237.         }
  1238.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1239.         {
  1240.             self.weapon = IT_ROCKET_LAUNCHER;
  1241.             if (self.ammo_rockets < 1)
  1242.                 am = 1;
  1243.         }
  1244.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1245.         {
  1246.             self.weapon = IT_LIGHTNING;
  1247.             if (self.ammo_cells < 1)
  1248.                 am = 1;
  1249.         }
  1250.     
  1251.         if ( (self.items & self.weapon) && am == 0)
  1252.         {
  1253.             W_SetCurrentAmmo ();
  1254.             return;
  1255.         }
  1256.     }
  1257.  
  1258. };
  1259.  
  1260. /*
  1261. ============
  1262. ServerflagsCommand
  1263.  
  1264. Just for development
  1265. ============
  1266. */
  1267. void() ServerflagsCommand =
  1268. {
  1269.     serverflags = serverflags * 2 + 1;
  1270. };
  1271.  
  1272. void() QuadCheat =
  1273. {
  1274.     if (deathmatch || coop)
  1275.         return;
  1276.     self.super_time = 1;
  1277.     self.super_damage_finished = time + 30;
  1278.     self.items = self.items | IT_QUAD;
  1279.     dprint ("quad cheat\n");
  1280. };
  1281.  
  1282. /*
  1283. ============
  1284. ImpulseCommands
  1285.  
  1286. ============
  1287. */
  1288. void() ImpulseCommands =
  1289. {
  1290.     if (self.impulse >= 1 && self.impulse <= 8)
  1291.         W_ChangeWeapon ();
  1292.  
  1293.     if (self.impulse == 9)
  1294.         CheatCommand ();
  1295.     if (self.impulse == 10)
  1296.         CycleWeaponCommand ();
  1297.     if (self.impulse == 11)
  1298.         ServerflagsCommand ();
  1299.  
  1300.     if (self.impulse == 255)
  1301.         QuadCheat ();
  1302.         
  1303.     self.impulse = 0;
  1304. };
  1305.  
  1306. /*
  1307. ============
  1308. W_WeaponFrame
  1309.  
  1310. Called every frame so impulse events can be handled as well as possible
  1311. ============
  1312. */
  1313. void() W_WeaponFrame =
  1314. {
  1315.     if (time < self.attack_finished)
  1316.         return;
  1317.  
  1318.     ImpulseCommands ();
  1319.     
  1320. // check for attack
  1321.     if (self.button0)
  1322.     {
  1323.         SuperDamageSound ();
  1324.         W_Attack ();
  1325.     }
  1326. };
  1327.  
  1328. /*
  1329. ========
  1330. SuperDamageSound
  1331.  
  1332. Plays sound if needed
  1333. ========
  1334. */
  1335. void() SuperDamageSound =
  1336. {
  1337.     if (self.super_damage_finished > time)
  1338.     {
  1339.         if (self.super_sound < time)
  1340.         {
  1341.             self.super_sound = time + 1;
  1342.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1343.         }
  1344.     }
  1345.     return;
  1346. };
  1347.  
  1348.  
  1349.